package com.mgl.util;

import java.util.ArrayList;

import com.mgl.movesprite.EntitySpriteLevelBase;
import com.mgl.movesprite.game.factory.GameType;

public class CircleList extends ArrayList<GameType>{

	private int position = 0;
	
	
	public GameType getFirst(){
		if(this.isEmpty()){
			return null;
		}
		return this.get(0);
	}
	
	public GameType getNext(){
		
		if(this.isEmpty()){
			return null;
		}
		
		try {
			position++;
			
			if(position>=this.size()){
				position = 0;
			}
			
			return this.get(position);
			
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
		
	}

	public GameType getPrev() {

		if(this.isEmpty()){
			return null;
		}
		
		try {
			
			position--;
			
			if(position<0){
				position = this.size()-1;
			}
			
			return this.get(position);
			
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
		
	}
	
}
